package com.eurabia.eggchat.controller.admin;

import com.eurabia.eggchat.VO.ResultVO;
import com.eurabia.eggchat.pojo.form.SysEggchatUserForm;
import com.eurabia.eggchat.service.SysEggchatLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 张会江
 * @version 1.0
 * @ClassName: SysCmsUserController
 * @Description: 用户操作相关方法
 * @Date 2018/5/24
 */
@RestController
@RequestMapping("/sysEggchatLogin")
public class SysEggchatLoginController {
    @Autowired
    private SysEggchatLoginService sysEggchatLoginService;



    /**
     * 通过用户名和密码登录
     * @param form
     * @return
     */
    @PostMapping(value = "/login")
    public final ResultVO login(final SysEggchatUserForm form, HttpServletRequest request) {
        return sysEggchatLoginService.login(form,request);
    }

    /**
     * 重置密码
     * @param form
     * @return
     */
    @PostMapping(value = "/updatePass")
    public final ResultVO updatePass(final SysEggchatUserForm form, HttpServletRequest request) {
        return sysEggchatLoginService.updateUserPass(form,request);
    }


    /**
     * 退出方法
     * @param request
     * @return
     */
    @PostMapping(value = "/loginOut")
    public final ResultVO loginOut( HttpServletRequest request) {

        return sysEggchatLoginService.loginOut(request);
    }

    /**
     * 注册方法
     * @param form
     * @return
     */
    @RequestMapping(value = "/regist", method = RequestMethod.POST)
    public final ResultVO regist(final SysEggchatUserForm form) {
        return sysEggchatLoginService.regist(form);

    }

    /**
     * 注销方法
     * @param id
     * @return
     */
    @RequestMapping(value = "/cancel", method = RequestMethod.POST)
    public final ResultVO cancel(Long id) {
        return sysEggchatLoginService.cancel(id);

    }
}